package bavaria.hightec.banking;




public class Money {
	private long amount;
	private Currency currency;
	private double[]exchangeRateList={0.76,0.69,1.13,0.025};//CHF,USD,GBP,RUB
	
	public Money(long betrag,Currency waehrung){
		this.amount=betrag;
		this.currency=waehrung;
		
	}
	
	
	public long addition(long betrag,Currency waehrung){
		if(waehrung == this.currency){
		this.amount=this.amount+betrag;
		}
		else{
			convert(betrag,waehrung);
		}
		return this.amount;
	}
	
	
	public boolean equals(Money money){
		boolean equal= false;
		if((this.amount==money.amount)&&(this.currency==money.currency))
			equal=true;
		return equal;
		
	}
	@Override
	public String toString(){
		String s="Betrag "+amount+" "+currency;
		return s;
	}
	
	
	public long getAmount(){
		return amount;
	}
	public Currency getCurrency(){
		return currency;
	}
	
	public long convert(long betrag,Currency waehrung){
		
		if(waehrung== Currency.CHF){
			betrag=(long) (betrag*exchangeRateList[0]);
		}
		else if(waehrung== Currency.USD){
			betrag=(long) (betrag*exchangeRateList[1]);
		}
		else if(waehrung== Currency.GBP){
			betrag=(long) (betrag*exchangeRateList[2]);
		}
		else if(waehrung== Currency.RUB){
			betrag=(long) (betrag*exchangeRateList[3]);
		}
		
		waehrung=Currency.EUR;
		
		return addition(betrag,waehrung);
		
	}
	
}



